/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.util;

import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 *
 * @author GiangLT
 */
public class ConfigFileUtil {

    public static List<File> listConfigFiles(String directory) throws Exception {
        File dir = new File(directory);
        if (dir.isDirectory()) {
            return Arrays.asList(dir.listFiles());
        } else {
            throw new Exception("Not a directory");
        }
    }

    public static void backupFile(File file) {
        DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        StringBuilder newFileName = new StringBuilder(file.getAbsolutePath());
        newFileName.append(".bak");
        newFileName.append(dateFormat.format(new Date()));

        File newFile = new File(newFileName.toString());
        if (newFile.exists()) //        FileUtils.
        {
            
        }
    }
}
